<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class MY_Model extends CI_Model {

    public $table = 'config';

    //添加数据
    public function create($data){
        $this->db->insert($this->table,$data);
        return $this->db->insert_id();
    }

    //查询
    public function select(){
        return $this->db->get($this->table)->result_array();
    }

    //统计
    public function get_count(){
        return $this->db->count_all_results($this->table);
    }
    // 查询单个数据
    public function get_one(){
        return $this->db->get($this->table)->row_array();
    }
    //删除数据
    public function delete(){
        return $this->db->delete($this->table);
    }
    //修改数据
    public function update($data = array()){
        if(empty($data)){
            $res = $this->db->update($this->table);
        }else{
            $res = $this->db->update($this->table,$data);
        }
        return $res;
    }

}

/* End of file MY_Model.php */
/* Location: ./application/core/MY_Model.php */